package controller

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func GetIndexData(ctx *gin.Context) {
	courses := eduCourseService.GetCacheCourse()
	if len(courses) < 1 {
		courses, _ = eduCourseService.SelectIndexHotCourse()
		eduCourseService.CacheCourses(courses)
	}
	teachers := eduTeacherService.GetCacheTeacher()
	if len(teachers) < 1 {
		teachers, _ = eduTeacherService.SelectIndexHotTeacher()
		eduTeacherService.CacheTeacher(teachers)
	}
	ctx.JSON(http.StatusOK, gin.H{
		"code":        20000,
		"courseList":  courses,
		"teacherList": teachers,
	})
	return
}
